package com.gateway.common.exception;

import com.gateway.common.enums.ResultEnum;

/**
 * 业务异常
 * 
 * @author ruoyi
 */
public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    protected final String message;

    protected final Integer code;

    public BusinessException(ResultEnum resultEnum) {
        this.code = resultEnum.getCode();
        this.message = resultEnum.getMessage();
    }

    public BusinessException(ResultEnum resultEnum, Throwable e, Integer code) {
        super(resultEnum.getMessage(), e);
        this.message = resultEnum.getMessage();
        this.code = resultEnum.getCode();
    }

    @Override
    public String getMessage() {
        return message;
    }

    public Integer getCode(){
        return code;
    }
}
